package org.courierframework.core.handler;

import java.io.Serializable;
import java.util.List;

/**
 * @author long.shiyu
 * @since 1.7
 */
public interface CrudHandler<T, ID extends Serializable> extends PersistenceHandler<T, ID> {
    /**
     * delete entity by id
     *
     * @param id unique key
     */
    void delete(ID id);

    /**
     * delete entities by  id array
     *
     * @param ids entity id array
     */
    void delete(ID[] ids);

    /**
     * save an entity to db
     *
     * @param entity the entity witch is to be persisted
     */
    void persist(T entity);

    /**
     * merge an entity to db
     *
     * @param entity the entity witch is to be merged
     */
    void merge(T entity);

    /**
     * find unique entity by id
     *
     * @param id entity id
     * @return entity
     */
    T findOne(ID id);

    /**
     * @param jpql  java persistence query language
     * @param prams parameters
     * @return list
     */
    List<T> findByJPQL(String jpql, Object... prams);
}
